Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Graphics /
Chapter 4 - Geometric Operations / Using Geometric Operations


Insetting Shapes

Whereas the GXSetShapeBounds function, illustrated in the previous section, provides a way to scale a shape, the GXInsetShape function provides a way to resize a shape relative to its original contours.

The sample function in Listing 4-9 creates a curve shape to use as an example.

Listing 4-9 Creating a tight curve shape

void CreateATightCurve(void)
{
   gxShape curveShape;

   const gxCurve tightCurveGeometry = {ff(90), ff(200), 
                                       ff(110), ff(0),  
                                       ff(120), ff(200)};


   curveShape = GXNewCurve(&tightCurveGeometry);
   GXSetShapeFill(curveShape, gxOpenFrameFill);

   GXDrawShape(curveShape);
   GXDisposeShape(curveShape);
}
The result of this function is shown in Figure 4-43.

Figure 4-43 A tight curve

If you apply

GXInsetShape(curveShape, ff(10));
to this curve, the function insets the curve a distance of 10.0 points from the original geometry, as shown in Figure 4-44. The resulting shape is a path shape with 16 geometric points.

Figure 4-44 An inset curve shape

You can use a shape's curve error to control the number of geometric points in the shape resulting from the inset operation. The result of the GXInsetShape function has no two consecutive points closer than the distance indicated by the shape's curve error.

The GXInsetShape function considers the contour direction when calculating an inset contour. For example, if you use

GXReverseShape(curveShape, 1);
to reverse the direction of the curve from Listing 4-9 before you inset the curve, the resulting path shape is actually outset from the original curve, as shown in Figure 4-45.

Figure 4-45 An outset curve

The contours created by the GXInsetShape function lie to the right of the original contours if you specify a positive distance and to the left of the original contours if you specify a negative distance. You can alter this behavior by setting the auto-inset style attribute, as described in Chapter 3, "Geometric Styles," in this book.

For more information about the GXInsetShape function, see page 4-94.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help